package auctionhausen

import grails.plugin.jms.Queue;



class ListingExpirationMonitorJob {

	def listingService

	//every 30 seconds to prevent CPU hog
	static triggers = {
		simple name: "CheckForListingExpiration", repeatInterval: 10000
	}

	def execute() {
		getNewlyExpiredListings().each { listingService.listingExpired(it) }
	}

	def getNewlyExpiredListings() {
		def query = Listing.where {
			expired != true && endDate <= new Date()
		}
		def listingList = query.findAll()
		return listingList
	}
}
